package com.qiya.LiaoDa.Fragment;

import android.graphics.Rect;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.qiya.LiaoDa.Fruit;
import com.qiya.LiaoDa.R;
import com.qiya.LiaoDa.Util.DividerItemDecorations;
import com.qiya.LiaoDa.ZViewPagerAdapter.LinearAdapter;
import com.qiya.LiaoDa.ZViewPagerAdapter.RecyclerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 *
 */
public class XYZXFragment extends Fragment {

    private List<Fruit> fruitList = new ArrayList<>();


    public XYZXFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_gwc, container, false);
        initFruits();
        return view;
    }
    @Override
    public void onStart() {
        super.onStart();
        initRv();
    }

    public void initRv(){
        RecyclerView recyclerView = getActivity().findViewById(R.id.recyclerView11);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this.getActivity());
        recyclerView.setLayoutManager(layoutManager);
        RecyclerAdapter adapter = new RecyclerAdapter(fruitList);
        recyclerView.setAdapter(adapter);
        recyclerView.addItemDecoration(new DividerItemDecorations());
    }

    private void initFruits() {
        for (int i = 0; i < 2; i++) {
            Fruit apple = new Fruit("四海快餐", R.drawable.fan2);
            fruitList.add(apple);
            Fruit appl1 = new Fruit("诚信快餐", R.drawable.fan3);
            fruitList.add(appl1);
            Fruit apple2 = new Fruit("重庆鸡公煲", R.drawable.fan4);
            fruitList.add(apple2);
            Fruit sadss = new Fruit("佰吉客汉堡", R.drawable.fan5);
            fruitList.add(sadss);
            Fruit dsad = new Fruit("真金道牛肉面", R.drawable.fan6);
            fruitList.add(dsad);
            Fruit dsa = new Fruit("小厨鸡架", R.drawable.fan7);
            fruitList.add(dsa);
            Fruit das = new Fruit("杨国福麻辣烫", R.drawable.fan1);
            fruitList.add(das);


        }
    }
}